home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / c_lib.arc / PCRETVEC.C < prev    next >
Text File  |  1990-08-09  |  2KB  |  56 lines

  1. /**
  2. *
  3. *  Name         pcretvec -- Return interrupt vector
  4. *
  5. *  Synopsis     ercode = pcretvec(intype,pvector);
  6. *               int ercode        Error return code
  7. *               int intype        Interrupt type number
  8. *               ADS *pvector      Interrupt vector
  9. *
  10. *  Description  This function returns the interrupt vector associated
  11. *               with the specified interrupt type.  The CS:IP vector is
  12. *               returned in the segment:offset components of *pvector.
  13. *
  14. *  Returns      ercode            If intype is not in the range 0 to 255
  15. *                                 1 is returned; otherwise 0.
  16. *               pvector           Interrupt vector (CS:IP address of
  17. *                                 of interrupt handling routine).
  18. *
  19. *  Version      1.0  (C)Copyright Blaise Computing Inc.  1983
  20. *
  21. **/
  22. #define utbyword(a,b)   (((a)<<8)|((b)&0x00ff))  /* a is high, b low   */
  23. #define utoutrng(a,l,h) (((a)<(l)||(a)>(h))?1:0) /* Is a out of range? */
  24.  
  25. struct segads                          /* Offset, segment address type */
  26. {
  27.   unsigned r;
  28.   unsigned s;
  29. };
  30. #define ADS     struct segads          /* Abbreviation                 */
  31.  
  32. struct dreg
  33. {
  34.   unsigned ax,bx,cx,dx,si,di,ds,es;
  35. };
  36. #define DOSREG  struct dreg
  37.  
  38. int pcretvec(intype,pvector)
  39. int intype;
  40. ADS *pvector;
  41. {
  42.  
  43.     DOSREG dos_reg;
  44.  
  45.     if (utoutrng(intype,0,255))
  46.        return(1);
  47.     utinit(&dos_reg);                  /* Initialize registers         */
  48.     dos_reg.ax = utbyword(0x35,intype);
  49.     dos(&dos_reg);
  50.     pvector->s = dos_reg.es;
  51.     pvector->r = dos_reg.bx;
  52.  
  53.     return(0);
  54.  
  55. }
  56.